package cn.cqie.attendance.manager.pojo;

import cn.afterturn.easypoi.excel.annotation.Excel;
import cn.afterturn.easypoi.handler.inter.IExcelModel;
import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.extension.activerecord.Model;
import com.fasterxml.jackson.annotation.JsonFormat;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.*;
import lombok.experimental.Accessors;
import org.springframework.format.annotation.DateTimeFormat;

import javax.validation.constraints.NotBlank;
import javax.validation.constraints.NotEmpty;
import javax.validation.constraints.NotNull;
import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.Date;

/**
 * @author 697
 * @date 2021/7/8 13:19
 */
@Data
@EqualsAndHashCode(callSuper = true)
@Accessors(chain = true)
@ApiModel(value="AttendancePunch对象", description="")
@ToString(onlyExplicitlyIncluded = true, includeFieldNames = false)
@AllArgsConstructor
@NoArgsConstructor
public class AdminAttendancePunch extends Model implements IExcelModel {

    private static final long serialVersionUID = -6076396448222680984L;

    private String errorMsg;

    @TableId(value = "id", type = IdType.AUTO)
    private int id;

    @DateTimeFormat(pattern = "yyyy-MM-dd")
    @JsonFormat(pattern = "yyyy-MM-dd",timezone = "GMT+8")
    @ApiModelProperty(value = "打卡日期")
    @Excel(name = "日期", format = "yyyy-MM-dd", width = 30)
    @NotNull(message = "打卡日期不能为空")
    @ToString.Include
    private Date punchDate;

    @ApiModelProperty(value = "学生学号")
    @Excel(name = "学号", width = 30)
    @NotBlank(message = "学号不能为空")
    @ToString.Include
    private String stuNumber;

    @ApiModelProperty(value = "学生名")
    @Excel(name = "姓名", width = 30)
    @NotBlank(message = "姓名不能为空")
    @ToString.Include
    private String stuName;

    @DateTimeFormat(pattern = "yyyy-MM-dd")
    @JsonFormat(pattern = "HH:mm:ss",timezone = "GMT+8")
    @ApiModelProperty(value = "打卡时间")
    @Excel(name = "打卡时间", format = "HH:mm:ss", width = 30)
    @NotNull(message = "打卡时间不能为空")
    @ToString.Include
    private Date trueSignInTime;

    @ApiModelProperty(value = "打卡设备(打卡的教室)")
    @Excel(name = "打卡设备", width = 30)
    @NotBlank(message = "打卡设备不能为空")
    @ToString.Include
    private String punchDevice;

    @Override
    public String getErrorMsg() {
        return errorMsg;
    }

    @Override
    public void setErrorMsg(String s) {
        this.errorMsg = s;
    }

    public AdminAttendancePunch(@NotNull(message = "打卡日期不能为空") Date punchDate, @NotBlank(message = "学号不能为空") String stuNumber, @NotBlank(message = "姓名不能为空") String stuName, @NotNull(message = "打卡时间不能为空") Date trueSignInTime, @NotBlank(message = "打卡设备不能为空") String punchDevice) {
        this.punchDate = punchDate;
        this.stuNumber = stuNumber;
        this.stuName = stuName;
        this.trueSignInTime = trueSignInTime;
        this.punchDevice = punchDevice;
    }
}
